<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="uft-8">
    <title>案例研究: JavaScript 图片</title>
</head>
<body>
<a href="http://localhost" onclick="return false">Clikc me</a>
<script>
    function javaScript() {
        function showPic(whichpic) {
            var source = whichpic.getAttribute('href');
            var placeholder = document.getElementById('placeholder');
            placeholder.setAttribute('src', source);

            function or() {
                placeholder = source;
            }
        }
    }

    function extension() {
        function childNodes() {
            var body = document.getElementsByTagName('body')[0];

            function or() {
                var childNodes = document.getElementsByTagName('body')[0].childNodes;
                var childNodesLength = childNodes.length;
            }

            function countBodyChildren() {
                var body = document.getElementsByTagName('body')[0];
                alert(body.childNodes.length);
            }

            window.onload = countBodyChildren;
        }

        function nodeType() {
            alert(document.body.nodeType);
        }

        function changeDescription() {
            function showPic(whichpic) {
                var source = whichpic.getAttribute('href');
                var placeholder = document.getElementById('placeholder');
                placeholder.setAttribute('src', source);
                var text = whichpic.getAttribute('href');
                var description = document.getElementById('description');
            }
        }

        function nodeValue() {
            var description = document.getElementById('description');
            alert(description.nodeValue);
            alert(description.childNodes[0].nodeValue);
        }

        function firstChild() {
            var description = document.getElementById('description');
            alert(description.nodeValue);
            alert(description.firstChild.nodeValue);
        }

        function useNodeValue() {
            function showPic(whichpic) {
                var source = whichpic.getAttribute('href');
                var placeholder = document.getElementById('placeholder');
                placeholder.setAttribute('src', source);
                var text = whichpic.getAttribute('href');
                var description = document.getElementById('description');
                description.firstChild.nodeValue = text;
            }
        }
    }
</script>
</body>
</html>